<?php


namespace app\home\service;


use app\home\model\dealer\Dealer;
use think\Request;
class TokenService
{
    public static function verifyToken($token){
        return $token ? true : false;
    }

    public static function getUserInfoFromToken($field){
        $token = Request::instance()->param('token');
        if (!$token){

           return CodeService::AUTH_TIMEOUT;
        }else{
            $model = new Dealer();
            $map = [
                'token' => $token
            ];
            $info = $model->where($map)->field(['phone','u_id'])->find();
            return !empty($info) ? $info[$field] : CodeService::AUTH_FAILD;

        }
    }

}